<template>
    <div class="main-panel">
        <div class="menus">
            <div v-for="(menu, index) in menus" @click="toPage(menu)">
                <n-button  quaternary @click="toHome">
                {{ menu.name }}
                </n-button>
                
            </div>
            <n-button  quaternary @click="toHome">
                主页
            </n-button>
        </div>

        <div class="subMenu">
            <router-view></router-view>
        </div>      
    </div>
    <div class="title">后台管理系统</div>
</template>


<script setup>
import { AdminStore } from "../../stores/AdminStore"
import { ref, reactive, inject } from "vue"
import { useRouter, useRoute} from 'vue-router'



const router = useRouter()
const route = useRoute()

const message = inject("message")
const axios = inject("axios")
const adminStore = AdminStore()

//菜单
let menus = [
    { name: "文章管理", href: "/dashboard/article" },
    { name: "分类管理", href: "/dashboard/category" },
    { name: "退出", href: "logout" },
];

const toPage = (menu) => {
    if(menu.href == 'logout'){
        router.push("/login")
    }else{
        router.push(menu.href)
    }
}


const toHome = () => {
    router.push("/")
}
</script>

<style lang="scss" scoped>
.main-panel {
    display: flex;
    color: black;
    max-width: 1500px;
    margin: 0 auto;
}

.menus {
    padding: 30px 0;
    box-sizing: border-box;
    line-height: 65px;
    text-align: center;
    width: 180px;
    height: 95vh;
    border-right: 1px solid rgb(223, 217, 217);

    div {
        cursor: pointer;
        &:hover{
            color: orange;
        }
    }
}

.subMenu {
    padding: 20px;
    width: 100%;
}

.title {
    font-size: 65px;
    font-weight: bold;
    text-align: right;
    position: fixed;
    color: rgba(0, 0, 0, 20%);
    right: calc((100vw - 1500px) / 2);
    bottom: 20px;
}
</style>